import { defHttp } from '@/utils/http/axios'
import type {
  RoleAddReq,
  RoleAssignModulesReq,
  RoleDeleteReq,
  RoleModuleQuery,
  RoleQuery,
  RoleResp,
  RoleUpdateReq,
} from '@/model/sys/roleModel'

enum Path {
  List = '/role/list',
  Add = '/role/add',
  Update = '/role/update',
  Delete = '/role/delete',
  Modules = '/role/modules',
  AssignModules = '/role/assign-modules',
}

export const roleApi = {
  list(params?: RoleQuery) {
    return defHttp.post<RoleResp>({ url: Path.List, params })
  },
  add(params: RoleAddReq) {
    return defHttp.post({ url: Path.Add, params })
  },
  update(params: RoleUpdateReq) {
    return defHttp.post({ url: Path.Update, params })
  },
  delete(params: RoleDeleteReq) {
    return defHttp.post({ url: Path.Delete, params })
  },
  modules(params: RoleModuleQuery) {
    return defHttp.post({ url: Path.Modules, params })
  },
  assignModules(params: RoleAssignModulesReq) {
    return defHttp.post({ url: Path.AssignModules, params })
  },
}
